

<!doctype html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>skidl.net &#8212; SKiDL 1.2.2 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../../_static/bizstyle.css?v=a66e137f" />
    
    <script src="../../_static/documentation_options.js?v=fd7cadf9"></script>
    <script src="../../_static/doctools.js?v=9a2dae69"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/bizstyle.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <!--[if lt IE 9]>
    <script src="_static/css3-mediaqueries.js"></script>
    <![endif]-->
  </head><body>
    <h1 id="site-title"><a href="../../../../"><img src="../../../../images/slim_banner.png" width="100%"></a></h1>
    
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SKiDL 1.2.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">skidl.net</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <h1>Source code for skidl.net</h1><div class="highlight"><pre>
<span></span><span class="c1"># -*- coding: utf-8 -*-</span>

<span class="c1"># The MIT License (MIT) - Copyright (c) Dave Vandenbout.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Handles nets.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span>  <span class="c1"># isort:skip</span>
    <span class="n">absolute_import</span><span class="p">,</span>
    <span class="n">division</span><span class="p">,</span>
    <span class="n">print_function</span><span class="p">,</span>
    <span class="n">unicode_literals</span><span class="p">,</span>
<span class="p">)</span>

<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">range</span><span class="p">,</span> <span class="nb">super</span>
<span class="kn">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</span><span class="p">,</span> <span class="n">deepcopy</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">future</span> <span class="kn">import</span> <span class="n">standard_library</span>

    <span class="n">standard_library</span><span class="o">.</span><span class="n">install_aliases</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="k">pass</span>

<span class="kn">from</span> <span class="nn">.erc</span> <span class="kn">import</span> <span class="n">dflt_net_erc</span>
<span class="kn">from</span> <span class="nn">.logger</span> <span class="kn">import</span> <span class="n">active_logger</span>
<span class="kn">from</span> <span class="nn">.skidlbaseobj</span> <span class="kn">import</span> <span class="n">SkidlBaseObject</span>
<span class="kn">from</span> <span class="nn">.utilities</span> <span class="kn">import</span> <span class="p">(</span>
    <span class="n">expand_buses</span><span class="p">,</span>
    <span class="n">expand_indices</span><span class="p">,</span>
    <span class="n">export_to_all</span><span class="p">,</span>
    <span class="n">filter_list</span><span class="p">,</span>
    <span class="n">find_num_copies</span><span class="p">,</span>
    <span class="n">flatten</span><span class="p">,</span>
    <span class="n">from_iadd</span><span class="p">,</span>
    <span class="n">get_unique_name</span><span class="p">,</span>
    <span class="n">rmv_iadd</span><span class="p">,</span>
    <span class="n">set_iadd</span><span class="p">,</span>
<span class="p">)</span>


<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;NET_PREFIX&quot;</span><span class="p">]</span>

<span class="c1"># Prefix for implicit nets.</span>
<span class="n">NET_PREFIX</span> <span class="o">=</span> <span class="s2">&quot;N$&quot;</span>

<span class="n">Traversal</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">namedtuple</span><span class="p">(</span><span class="s2">&quot;Traversal&quot;</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;nets&quot;</span><span class="p">,</span> <span class="s2">&quot;pins&quot;</span><span class="p">])</span>


<div class="viewcode-block" id="Net">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net">[docs]</a>
<span class="nd">@export_to_all</span>
<span class="k">class</span> <span class="nc">Net</span><span class="p">(</span><span class="n">SkidlBaseObject</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Lists of connected pins are stored as nets using this class.</span>

<span class="sd">    Args:</span>
<span class="sd">        name: A string with the name of the net. If None or &#39;&#39;, then</span>
<span class="sd">            a unique net name will be assigned.</span>
<span class="sd">        circuit: The Circuit object this net belongs to.</span>
<span class="sd">        *pins_nets_buses: One or more Pin, Net, or Bus objects or</span>
<span class="sd">            lists/tuples of them to be connected to this net.</span>

<span class="sd">    Keyword Args:</span>
<span class="sd">        attribs: A dictionary of attributes and values to attach to</span>
<span class="sd">            the Net object.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># Set the default ERC functions for all Net instances.</span>
    <span class="n">erc_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">dflt_net_erc</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">):</span>
        <span class="kn">from</span> <span class="nn">.pin</span> <span class="kn">import</span> <span class="n">Pin</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_valid</span> <span class="o">=</span> <span class="kc">True</span>  <span class="c1"># Make net valid before doing anything else.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">do_erc</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_drive</span> <span class="o">=</span> <span class="n">Pin</span><span class="o">.</span><span class="n">drives</span><span class="o">.</span><span class="n">NONE</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="kc">None</span>  <span class="c1"># This is the net number used in a KiCad netlist file.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">stub</span> <span class="o">=</span> <span class="kc">False</span>  <span class="c1"># Net is not a stub for schematic generation.</span>

        <span class="c1"># Set the net name directly to the passed-in name without any adjustment.</span>
        <span class="c1"># The net name will be adjusted when it is added to the circuit which</span>
        <span class="c1"># may already have a net with the same name.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_name</span> <span class="o">=</span> <span class="n">name</span>

        <span class="c1"># Add the net to the passed-in circuit or to the default circuit.</span>
        <span class="n">circuit</span> <span class="o">=</span> <span class="n">circuit</span> <span class="ow">or</span> <span class="n">default_circuit</span>
        <span class="n">circuit</span> <span class="o">+=</span> <span class="bp">self</span>

        <span class="c1"># Attach whatever pins were given.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">pins_nets_buses</span><span class="p">)</span>
        <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">iadd_flag</span>  <span class="c1"># Remove the += flag inserted by connect().</span>

        <span class="c1"># Attach additional attributes to the net.</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">attribs</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
            <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__bool__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Any valid Net is True&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="n">__nonzero__</span> <span class="o">=</span> <span class="fm">__bool__</span>  <span class="c1"># Python 2 compatibility.</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return a list of the pins on this net as a string.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">pins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pins</span>
        <span class="k">return</span> <span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">+</span> <span class="s2">&quot;: &quot;</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">p</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">pins</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="nb">str</span><span class="p">)])</span>
        <span class="p">)</span>

    <span class="fm">__repr__</span> <span class="o">=</span> <span class="fm">__str__</span>  <span class="c1"># TODO: This is a temporary fix. The __repr__ should be more informative.</span>

    <span class="c1"># Use += to connect to nets.</span>
    <span class="k">def</span> <span class="fm">__iadd__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return the net after connecting other pins, nets, and buses to it.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__and__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Attach a net and another part/pin/net in serial.&quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">.network</span> <span class="kn">import</span> <span class="n">Network</span>

        <span class="k">return</span> <span class="n">Network</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">obj</span>

    <span class="k">def</span> <span class="fm">__rand__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Attach a net and another part/pin/net in serial.&quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">.network</span> <span class="kn">import</span> <span class="n">Network</span>

        <span class="k">return</span> <span class="n">obj</span> <span class="o">&amp;</span> <span class="n">Network</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__or__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Attach a net and another part/pin/net in parallel.&quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">.network</span> <span class="kn">import</span> <span class="n">Network</span>

        <span class="k">return</span> <span class="n">Network</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">|</span> <span class="n">obj</span>

    <span class="k">def</span> <span class="fm">__ror__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Attach a net and another part/pin/net in parallel.&quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">.network</span> <span class="kn">import</span> <span class="n">Network</span>

        <span class="k">return</span> <span class="n">obj</span> <span class="o">|</span> <span class="n">Network</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return the number of pins attached to this net.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pins</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ids</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return the net if the indices resolve to a single index of 0.</span>

<span class="sd">        Args:</span>
<span class="sd">            ids: A list of indices. These can be individual</span>
<span class="sd">                numbers, net names, nested lists, or slices.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The net, otherwise None or raises an Exception.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Resolve the indices.</span>
        <span class="n">indices</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">expand_indices</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">width</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="o">*</span><span class="n">ids</span><span class="p">)))</span>
        <span class="k">if</span> <span class="n">indices</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">indices</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">indices</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="s2">&quot;Can&#39;t index a net with multiple indices.&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="s2">&quot;Can&#39;t use a non-zero index for a net.&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="fm">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ids</span><span class="p">,</span> <span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        You can&#39;t assign to Nets. You must use the += operator.</span>

<span class="sd">        This method is a work-around that allows the use of the += for making</span>
<span class="sd">        connections to nets while prohibiting direct assignment. Python</span>
<span class="sd">        processes something like net[0] += Pin() as follows::</span>

<span class="sd">            1. Net.__getitem__ is called with &#39;0&#39; as the index. This</span>
<span class="sd">               returns a single Net.</span>
<span class="sd">            2. The Net.__iadd__ method is passed the net and</span>
<span class="sd">               the thing to connect to it (a Pin in this case). This</span>
<span class="sd">               method makes the actual connection to the pin. Then</span>
<span class="sd">               it creates an iadd_flag attribute in the object it returns.</span>
<span class="sd">            3. Finally, Net.__setitem__ is called. If the iadd_flag attribute</span>
<span class="sd">               is true in the passed argument, then __setitem__ was entered</span>
<span class="sd">               as part of processing the += operator. If there is no</span>
<span class="sd">               iadd_flag attribute, then __setitem__ was entered as a result</span>
<span class="sd">               of using a direct assignment, which is not allowed.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># If the iadd_flag is set, then it&#39;s OK that we got</span>
        <span class="c1"># here and don&#39;t issue an error. Also, delete the flag.</span>
        <span class="k">if</span> <span class="n">from_iadd</span><span class="p">(</span><span class="n">pins_nets_buses</span><span class="p">):</span>
            <span class="n">rmv_iadd</span><span class="p">(</span><span class="n">pins_nets_buses</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># No iadd_flag or it wasn&#39;t set. This means a direct assignment</span>
        <span class="c1"># was made to the pin, which is not allowed.</span>
        <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span><span class="ne">TypeError</span><span class="p">,</span> <span class="s2">&quot;Can&#39;t assign to a Net! Use the += operator.&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return an iterator for stepping through the net.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># You can only iterate a Net one time.</span>
        <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">])</span>  <span class="c1"># Return generator expr.</span>

    <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num_copies</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Make one or more copies of this net.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">num_copies</span><span class="o">=</span><span class="n">num_copies</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="n">circuit</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__mul__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num_copies</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Use multiplication operator to make copies of a net.&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">num_copies</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">num_copies</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">num_copies</span><span class="o">=</span><span class="n">num_copies</span><span class="p">)</span>

    <span class="fm">__rmul__</span> <span class="o">=</span> <span class="fm">__mul__</span>

<div class="viewcode-block" id="Net.get">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.get">[docs]</a>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get the net with the given name from a circuit, or return None.&quot;&quot;&quot;</span>

        <span class="kn">from</span> <span class="nn">.alias</span> <span class="kn">import</span> <span class="n">Alias</span>

        <span class="n">circuit</span> <span class="o">=</span> <span class="n">circuit</span> <span class="ow">or</span> <span class="n">default_circuit</span>

        <span class="n">search_params</span> <span class="o">=</span> <span class="p">((</span><span class="s2">&quot;name&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> <span class="p">(</span><span class="s2">&quot;aliases&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="kc">True</span><span class="p">))</span>

        <span class="k">for</span> <span class="n">attr</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">do_str_match</span> <span class="ow">in</span> <span class="n">search_params</span><span class="p">:</span>
            <span class="c1"># filter_list() always returns a list. A net can consist of multiple</span>
            <span class="c1"># interconnected Net objects. If the list is non-empty,</span>
            <span class="c1"># just return the first Net object on the list.</span>
            <span class="n">nets</span> <span class="o">=</span> <span class="n">filter_list</span><span class="p">(</span><span class="n">circuit</span><span class="o">.</span><span class="n">nets</span><span class="p">,</span> <span class="n">do_str_match</span><span class="o">=</span><span class="n">do_str_match</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span><span class="n">attr</span><span class="p">:</span> <span class="n">name</span><span class="p">})</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
                <span class="k">pass</span>

        <span class="k">return</span> <span class="kc">None</span></div>


<div class="viewcode-block" id="Net.fetch">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.fetch">[docs]</a>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">fetch</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get the net with the given name from a circuit, or create it if not found.&quot;&quot;&quot;</span>

        <span class="n">circuit</span> <span class="o">=</span> <span class="n">attribs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;circuit&quot;</span><span class="p">,</span> <span class="n">default_circuit</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="n">circuit</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">cls</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">)</span></div>


<div class="viewcode-block" id="Net.get_pins">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.get_pins">[docs]</a>
    <span class="k">def</span> <span class="nf">get_pins</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return a list of pins attached to this net.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_traverse</span><span class="p">()</span><span class="o">.</span><span class="n">pins</span></div>


<div class="viewcode-block" id="Net.get_nets">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.get_nets">[docs]</a>
    <span class="k">def</span> <span class="nf">get_nets</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return a list of nets attached to this net, including this net.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_traverse</span><span class="p">()</span><span class="o">.</span><span class="n">nets</span></div>


<div class="viewcode-block" id="Net.is_attached">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.is_attached">[docs]</a>
    <span class="k">def</span> <span class="nf">is_attached</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pin_net_bus</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return true if the pin, net or bus is attached to this one.&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pin_net_bus</span><span class="p">,</span> <span class="n">Net</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">pin_net_bus</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pin_net_bus</span><span class="p">,</span> <span class="n">Pin</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">pin_net_bus</span><span class="o">.</span><span class="n">is_attached</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pin_net_bus</span><span class="p">,</span> <span class="n">Bus</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">net</span> <span class="ow">in</span> <span class="n">pin_net_bus</span><span class="p">[:]:</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_attached</span><span class="p">(</span><span class="n">net</span><span class="p">):</span>
                    <span class="k">return</span> <span class="kc">True</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
            <span class="ne">TypeError</span><span class="p">,</span> <span class="s2">&quot;Nets can&#39;t be attached to </span><span class="si">{}</span><span class="s2">!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">pin_net_bus</span><span class="p">))</span>
        <span class="p">)</span></div>


<div class="viewcode-block" id="Net.is_movable">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.is_movable">[docs]</a>
    <span class="k">def</span> <span class="nf">is_movable</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return true if the net is movable to another circuit.</span>

<span class="sd">        A net is movable if it&#39;s not part of a Circuit or if there are no pins</span>
<span class="sd">        attached to it.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">from</span> <span class="nn">.circuit</span> <span class="kn">import</span> <span class="n">Circuit</span>

        <span class="k">return</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">circuit</span><span class="p">,</span> <span class="n">Circuit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span></div>


<div class="viewcode-block" id="Net.is_implicit">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.is_implicit">[docs]</a>
    <span class="k">def</span> <span class="nf">is_implicit</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return true if the net name is implicit.&quot;&quot;&quot;</span>

        <span class="kn">from</span> <span class="nn">.bus</span> <span class="kn">import</span> <span class="n">BUS_PREFIX</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">prefix_re</span> <span class="o">=</span> <span class="s2">&quot;(</span><span class="si">{}</span><span class="s2">|</span><span class="si">{}</span><span class="s2">)+&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">re</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="n">NET_PREFIX</span><span class="p">),</span> <span class="n">re</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="n">BUS_PREFIX</span><span class="p">))</span>
        <span class="k">return</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">prefix_re</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span></div>


<div class="viewcode-block" id="Net.copy">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.copy">[docs]</a>
    <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num_copies</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Make zero or more copies of this net.</span>

<span class="sd">        Args:</span>
<span class="sd">            num_copies: Number of copies to make of this net.</span>

<span class="sd">        Keyword Args:</span>
<span class="sd">            attribs: Name/value pairs for setting attributes for the copy.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A list of Net copies or a Net if num_copies==1.</span>

<span class="sd">        Raises:</span>
<span class="sd">            Exception if the requested number of copies is a non-integer or negative.</span>

<span class="sd">        Notes:</span>
<span class="sd">            An instance of a net can be copied just by calling it like so::</span>

<span class="sd">                n = Net(&#39;A&#39;)    # Create a net.</span>
<span class="sd">                n_copy = n()    # Copy the net.</span>

<span class="sd">            You can also use the multiplication operator to make copies::</span>

<span class="sd">                n = 10 * Net(&#39;A&#39;)  # Create an array of nets.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>

        <span class="c1"># If the number of copies is None, then a single copy will be made</span>
        <span class="c1"># and returned as a scalar (not a list). Otherwise, the number of</span>
        <span class="c1"># copies will be set by the num_copies parameter or the number of</span>
        <span class="c1"># values supplied for each part attribute.</span>
        <span class="n">num_copies_attribs</span> <span class="o">=</span> <span class="n">find_num_copies</span><span class="p">(</span><span class="o">**</span><span class="n">attribs</span><span class="p">)</span>
        <span class="n">return_list</span> <span class="o">=</span> <span class="p">(</span><span class="n">num_copies</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">num_copies_attribs</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">num_copies</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">num_copies</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">num_copies_attribs</span><span class="p">)</span>

        <span class="c1"># Check that a valid number of copies is requested.</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">num_copies</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
            <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                <span class="ne">ValueError</span><span class="p">,</span>
                <span class="s2">&quot;Can&#39;t make a non-integer number &quot;</span>
                <span class="s2">&quot;(</span><span class="si">{}</span><span class="s2">) of copies of a net!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">num_copies</span><span class="p">),</span>
            <span class="p">)</span>
        <span class="k">if</span> <span class="n">num_copies</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                <span class="ne">ValueError</span><span class="p">,</span>
                <span class="s2">&quot;Can&#39;t make a negative number &quot;</span>
                <span class="s2">&quot;(</span><span class="si">{}</span><span class="s2">) of copies of a net!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">num_copies</span><span class="p">),</span>
            <span class="p">)</span>

        <span class="c1"># If circuit is not specified, then create the copies within circuit of the</span>
        <span class="c1"># original, or in the default circuit.</span>
        <span class="n">circuit</span> <span class="o">=</span> <span class="n">circuit</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span> <span class="ow">or</span> <span class="n">default_circuit</span>

        <span class="c1"># Can&#39;t make a distinct copy of a net which already has pins on it</span>
        <span class="c1"># because what happens if a pin is connected to the copy? Then we have</span>
        <span class="c1"># to search for all the other copies to add the pin to those.</span>
        <span class="c1"># And what&#39;s the value of that?</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">:</span>
            <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                <span class="ne">ValueError</span><span class="p">,</span>
                <span class="s2">&quot;Can&#39;t make copies of a net that already has &quot;</span> <span class="s2">&quot;pins attached to it!&quot;</span><span class="p">,</span>
            <span class="p">)</span>

        <span class="c1"># Create a list of copies of this net.</span>
        <span class="n">copies</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">num_copies</span><span class="p">):</span>

            <span class="c1"># Create a new net to store the copy.</span>
            <span class="n">cpy</span> <span class="o">=</span> <span class="n">Net</span><span class="p">(</span><span class="n">circuit</span><span class="o">=</span><span class="n">circuit</span><span class="p">)</span>

            <span class="c1"># Deep copy attributes from the source net to the copy.</span>
            <span class="c1"># Skip some attributes that would cause an infinite recursion exception.</span>
            <span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__dict__</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;circuit&#39;</span><span class="p">,</span> <span class="s1">&#39;traversal&#39;</span><span class="p">]:</span>
                    <span class="nb">setattr</span><span class="p">(</span><span class="n">cpy</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">deepcopy</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>

            <span class="c1"># Add other attributes to the net copy.</span>
            <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">attribs</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
                <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">v</span> <span class="o">=</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
                    <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
                        <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                            <span class="ne">ValueError</span><span class="p">,</span>
                            <span class="p">(</span>
                                <span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> copies of net </span><span class="si">{}</span><span class="s2"> were requested, but too &quot;</span>
                                <span class="s2">&quot;few elements in attribute </span><span class="si">{}</span><span class="s2">!&quot;</span>
                            <span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">num_copies</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">k</span><span class="p">),</span>
                        <span class="p">)</span>
                <span class="nb">setattr</span><span class="p">(</span><span class="n">cpy</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>

            <span class="c1"># Place the copy into the list of copies.</span>
            <span class="n">copies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cpy</span><span class="p">)</span>

        <span class="c1"># Return a list of the copies made or just a single copy.</span>
        <span class="k">if</span> <span class="n">return_list</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">copies</span>
        <span class="k">return</span> <span class="n">copies</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>


<div class="viewcode-block" id="Net.connect">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.connect">[docs]</a>
    <span class="k">def</span> <span class="nf">connect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return the net after connecting other pins, nets, and buses to it.</span>

<span class="sd">        Args:</span>
<span class="sd">            *pins_nets_buses: One or more Pin, Net, or Bus objects or</span>
<span class="sd">                lists/tuples of them to be connected to this net.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The updated net with the new connections.</span>

<span class="sd">        Notes:</span>
<span class="sd">            Connections to nets can also be made using the += operator like so::</span>

<span class="sd">                atmega = Part(&#39;atmel&#39;, &#39;ATMEGA16U2&#39;)</span>
<span class="sd">                net = Net()</span>
<span class="sd">                net += atmega[1]  # Connects pin 1 of chip to the net.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">from</span> <span class="nn">.pin</span> <span class="kn">import</span> <span class="n">PhantomPin</span><span class="p">,</span> <span class="n">Pin</span>
        <span class="kn">from</span> <span class="nn">.protonet</span> <span class="kn">import</span> <span class="n">ProtoNet</span>

        <span class="k">def</span> <span class="nf">join</span><span class="p">(</span><span class="n">net</span><span class="p">):</span>
<span class="w">            </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            Join nets by giving them each a pin in common.</span>

<span class="sd">            Args:</span>
<span class="sd">                net: The net to join with self.</span>
<span class="sd">            &quot;&quot;&quot;</span>

            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">NCNet</span><span class="p">):</span>
                <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                    <span class="ne">ValueError</span><span class="p">,</span>
                    <span class="s2">&quot;Can&#39;t join with a no-connect net </span><span class="si">{}</span><span class="s2">!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">),</span>
                <span class="p">)</span>

            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">net</span><span class="p">,</span> <span class="n">NCNet</span><span class="p">):</span>
                <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                    <span class="ne">ValueError</span><span class="p">,</span>
                    <span class="s2">&quot;Can&#39;t join with a no-connect net </span><span class="si">{}</span><span class="s2">!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">net</span><span class="o">.</span><span class="n">name</span><span class="p">),</span>
                <span class="p">)</span>

            <span class="c1"># No need to do anything if merging a net with itself.</span>
            <span class="k">if</span> <span class="bp">self</span> <span class="o">==</span> <span class="n">net</span><span class="p">:</span>
                <span class="k">return</span>

            <span class="c1"># If this net has pins, just attach the other net to one of them.</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">nets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">net</span><span class="p">)</span>
                <span class="n">net</span><span class="o">.</span><span class="n">_pins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="c1"># If the other net has pins, attach this net to a pin on the other net.</span>
            <span class="k">elif</span> <span class="n">net</span><span class="o">.</span><span class="n">_pins</span><span class="p">:</span>
                <span class="n">net</span><span class="o">.</span><span class="n">_pins</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">nets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">net</span><span class="o">.</span><span class="n">_pins</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="c1"># If neither net has any pins, then attach a phantom pin to one net</span>
            <span class="c1"># and then connect the nets together.</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">p</span> <span class="o">=</span> <span class="n">PhantomPin</span><span class="p">()</span>
                <span class="n">connect_pin</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">nets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">net</span><span class="p">)</span>
                <span class="n">net</span><span class="o">.</span><span class="n">_pins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>

            <span class="c1"># Update the drive of the joined nets. When setting the drive of a</span>
            <span class="c1"># net the net drive will be the maximum of its current drive or the</span>
            <span class="c1"># new drive. So the following two operations will set each net</span>
            <span class="c1"># drive to the same maximum value.</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">drive</span> <span class="o">=</span> <span class="n">net</span><span class="o">.</span><span class="n">drive</span>
            <span class="n">net</span><span class="o">.</span><span class="n">drive</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">drive</span>

            <span class="c1"># Update the net class of the joined nets. The following two</span>
            <span class="c1"># operations will set each net&#39;s class to the same value, or</span>
            <span class="c1"># throw an error if they are in different classes.</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">netclass</span> <span class="o">=</span> <span class="n">net</span><span class="o">.</span><span class="n">netclass</span>
            <span class="n">net</span><span class="o">.</span><span class="n">netclass</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">netclass</span>

        <span class="k">def</span> <span class="nf">connect_pin</span><span class="p">(</span><span class="n">pin</span><span class="p">):</span>
<span class="w">            </span><span class="sd">&quot;&quot;&quot;Connect a pin to this net.&quot;&quot;&quot;</span>
            <span class="k">if</span> <span class="n">pin</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">:</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">pin</span><span class="o">.</span><span class="n">is_connected</span><span class="p">():</span>
                    <span class="c1"># Remove the pin from the no-connect net if it is attached to it.</span>
                    <span class="n">pin</span><span class="o">.</span><span class="n">disconnect</span><span class="p">()</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pin</span><span class="p">)</span>
                <span class="n">pin</span><span class="o">.</span><span class="n">nets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
                <span class="n">pin</span><span class="o">.</span><span class="n">stub</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">stub</span>  <span class="c1"># Update pin stub net for generating schematics.</span>
            <span class="k">return</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>

        <span class="c1"># Go through all the pins and/or nets and connect them to this net.</span>
        <span class="k">for</span> <span class="n">pn</span> <span class="ow">in</span> <span class="n">expand_buses</span><span class="p">(</span><span class="n">flatten</span><span class="p">(</span><span class="n">pins_nets_buses</span><span class="p">)):</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pn</span><span class="p">,</span> <span class="n">ProtoNet</span><span class="p">):</span>
                <span class="n">pn</span> <span class="o">+=</span> <span class="bp">self</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pn</span><span class="p">,</span> <span class="n">Net</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">pn</span><span class="o">.</span><span class="n">circuit</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span><span class="p">:</span>
                    <span class="n">join</span><span class="p">(</span><span class="n">pn</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                        <span class="ne">ValueError</span><span class="p">,</span>
                        <span class="s2">&quot;Can&#39;t attach nets in different circuits (</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">pn</span><span class="o">.</span><span class="n">circuit</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span><span class="o">.</span><span class="n">name</span>
                        <span class="p">),</span>
                    <span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pn</span><span class="p">,</span> <span class="n">Pin</span><span class="p">):</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">pn</span><span class="o">.</span><span class="n">part</span> <span class="ow">or</span> <span class="n">pn</span><span class="o">.</span><span class="n">part</span><span class="o">.</span><span class="n">circuit</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span><span class="p">:</span>
                    <span class="k">if</span> <span class="ow">not</span> <span class="n">pn</span><span class="o">.</span><span class="n">part</span><span class="p">:</span>
                        <span class="n">active_logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
                            <span class="s2">&quot;Attaching non-part Pin </span><span class="si">{}</span><span class="s2"> to a Net </span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                <span class="n">pn</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
                            <span class="p">)</span>
                        <span class="p">)</span>
                    <span class="n">connect_pin</span><span class="p">(</span><span class="n">pn</span><span class="p">)</span>
                <span class="k">elif</span> <span class="ow">not</span> <span class="n">pn</span><span class="o">.</span><span class="n">part</span><span class="o">.</span><span class="n">circuit</span><span class="p">:</span>
                    <span class="n">active_logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
                        <span class="s2">&quot;Attaching part template Pin </span><span class="si">{}</span><span class="s2"> to a Net </span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">pn</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
                        <span class="p">)</span>
                    <span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                        <span class="ne">ValueError</span><span class="p">,</span>
                        <span class="s2">&quot;Can&#39;t attach a part to a net in different circuits (</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">pn</span><span class="o">.</span><span class="n">part</span><span class="o">.</span><span class="n">circuit</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span><span class="o">.</span><span class="n">name</span>
                        <span class="p">),</span>
                    <span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                    <span class="ne">TypeError</span><span class="p">,</span>
                    <span class="s2">&quot;Cannot attach non-Pin/non-Net </span><span class="si">{}</span><span class="s2"> to Net </span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="nb">type</span><span class="p">(</span><span class="n">pn</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
                    <span class="p">),</span>
                <span class="p">)</span>

        <span class="c1"># If something has been connected to a net, then recompute its traversal so the</span>
        <span class="c1"># correct number of connected pins and nets is recorded.</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span>
        <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
            <span class="k">pass</span>  <span class="c1"># No traversal to delete.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_traverse</span><span class="p">()</span>

        <span class="c1"># Add the net to the global netlist. (It won&#39;t be added again</span>
        <span class="c1"># if it&#39;s already there.)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">circuit</span> <span class="o">+=</span> <span class="bp">self</span>

        <span class="c1"># Set the flag to indicate this result came from the += operator.</span>
        <span class="n">set_iadd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>


<div class="viewcode-block" id="Net.disconnect">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.disconnect">[docs]</a>
    <span class="k">def</span> <span class="nf">disconnect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pin</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Remove the pin from this net but not any other nets it&#39;s attached to.&quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">pin</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
            <span class="k">return</span>  <span class="c1"># Pin wasn&#39;t in the list, so abort.</span>

        <span class="c1"># If a pin has been disconnected from a net, then remove any existing traversal</span>
        <span class="c1"># so it will be recomputed the next time it is needed.</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span>
        <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
            <span class="k">pass</span>  <span class="c1"># No traversal to delete.</span></div>


<div class="viewcode-block" id="Net.merge_names">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.merge_names">[docs]</a>
    <span class="k">def</span> <span class="nf">merge_names</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;For multi-segment nets, select a common name for all the segments.&quot;&quot;&quot;</span>

        <span class="k">def</span> <span class="nf">select_name</span><span class="p">(</span><span class="n">nets</span><span class="p">):</span>
<span class="w">            </span><span class="sd">&quot;&quot;&quot;Return the net with the best name among a list of nets.&quot;&quot;&quot;</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">nets</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">None</span>  <span class="c1"># No nets, return None.</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">nets</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># One net, return it.</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">nets</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                <span class="c1"># Two nets, return the best of them.</span>
                <span class="n">name0</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;name&quot;</span><span class="p">)</span>
                <span class="n">name1</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">nets</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s2">&quot;name&quot;</span><span class="p">)</span>
                <span class="n">fixed0</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;fixed_name&quot;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
                <span class="n">fixed1</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">nets</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s2">&quot;fixed_name&quot;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">name1</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">name0</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">fixed0</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">fixed1</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">fixed1</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">fixed0</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">fixed0</span> <span class="ow">and</span> <span class="n">fixed1</span><span class="p">:</span>
                    <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                        <span class="ne">ValueError</span><span class="p">,</span>
                        <span class="s2">&quot;Cannot merge two nets with fixed names: </span><span class="si">{}</span><span class="s2"> and </span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">name0</span><span class="p">,</span> <span class="n">name1</span>
                        <span class="p">),</span>
                    <span class="p">)</span>
                <span class="k">if</span> <span class="n">nets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">is_implicit</span><span class="p">():</span>
                    <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">is_implicit</span><span class="p">():</span>
                    <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">name0</span> <span class="o">!=</span> <span class="n">name1</span><span class="p">:</span>
                    <span class="n">active_logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
                        <span class="s2">&quot;Merging two named nets (</span><span class="si">{name0}</span><span class="s2"> and </span><span class="si">{name1}</span><span class="s2">) into </span><span class="si">{name0}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="o">**</span><span class="nb">locals</span><span class="p">()</span>
                        <span class="p">)</span>
                    <span class="p">)</span>
                <span class="k">return</span> <span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

            <span class="c1"># More than two nets, so bisect the list into two smaller lists and</span>
            <span class="c1"># recursively find the best name from each list and then return the</span>
            <span class="c1"># best name of those two.</span>
            <span class="n">mid_point</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">nets</span><span class="p">)</span> <span class="o">//</span> <span class="mi">2</span>
            <span class="k">return</span> <span class="n">select_name</span><span class="p">(</span>
                <span class="p">[</span><span class="n">select_name</span><span class="p">(</span><span class="n">nets</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="n">mid_point</span><span class="p">]),</span> <span class="n">select_name</span><span class="p">(</span><span class="n">nets</span><span class="p">[</span><span class="n">mid_point</span><span class="p">:])]</span>
            <span class="p">)</span>

        <span class="c1"># Assign the same name to all the nets that are connected to this net.</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>
        <span class="n">selected_name</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">select_name</span><span class="p">(</span><span class="n">nets</span><span class="p">),</span> <span class="s2">&quot;name&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">net</span> <span class="ow">in</span> <span class="n">nets</span><span class="p">:</span>
            <span class="c1"># Assign the name directly to each net. Using the name property</span>
            <span class="c1"># would cause the names to be changed so they were unique.</span>
            <span class="n">net</span><span class="o">.</span><span class="n">_name</span> <span class="o">=</span> <span class="n">selected_name</span>  <span class="c1"># pylint: disable=protected-access</span></div>


<div class="viewcode-block" id="Net.create_network">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.create_network">[docs]</a>
    <span class="k">def</span> <span class="nf">create_network</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Create a network from a single net.&quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">.network</span> <span class="kn">import</span> <span class="n">Network</span>

        <span class="n">ntwk</span> <span class="o">=</span> <span class="n">Network</span><span class="p">()</span>
        <span class="n">ntwk</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">ntwk</span></div>


<div class="viewcode-block" id="Net.generate_netlist_net">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.generate_netlist_net">[docs]</a>
    <span class="k">def</span> <span class="nf">generate_netlist_net</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tool</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate the net information for inclusion in a netlist.</span>

<span class="sd">        Args:</span>
<span class="sd">            tool: The format for the netlist file (e.g., KICAD).</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">skidl</span>

        <span class="kn">from</span> <span class="nn">.tools</span> <span class="kn">import</span> <span class="n">tool_modules</span>

        <span class="n">tool</span> <span class="o">=</span> <span class="n">tool</span> <span class="ow">or</span> <span class="n">skidl</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">tool</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>

        <span class="c1"># Don&#39;t add anything to the netlist if no pins are on this net.</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pins</span><span class="p">:</span>
            <span class="k">return</span>

        <span class="k">return</span> <span class="n">tool_modules</span><span class="p">[</span><span class="n">tool</span><span class="p">]</span><span class="o">.</span><span class="n">gen_netlist_net</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span></div>


<div class="viewcode-block" id="Net.generate_xml_net">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.generate_xml_net">[docs]</a>
    <span class="k">def</span> <span class="nf">generate_xml_net</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tool</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate the net information for inclusion in an XML file.</span>

<span class="sd">        Args:</span>
<span class="sd">            tool: The format for the XML file (e.g., KICAD).</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">skidl</span>

        <span class="kn">from</span> <span class="nn">.tools</span> <span class="kn">import</span> <span class="n">tool_modules</span>

        <span class="n">tool</span> <span class="o">=</span> <span class="n">tool</span> <span class="ow">or</span> <span class="n">skidl</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">tool</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>

        <span class="c1"># Don&#39;t add anything to the XML if no pins are on this net.</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pins</span><span class="p">:</span>
            <span class="k">return</span>

        <span class="k">return</span> <span class="n">tool_modules</span><span class="p">[</span><span class="n">tool</span><span class="p">]</span><span class="o">.</span><span class="n">gen_xml_net</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span></div>


    <span class="k">def</span> <span class="nf">_traverse</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return all the nets and pins attached to this net, including itself.&quot;&quot;&quot;</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span>  <span class="c1"># Return pre-existing traversal.</span>
        <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
            <span class="k">pass</span>  <span class="c1"># Compute the traversal if it&#39;s not available.</span>

        <span class="kn">from</span> <span class="nn">.pin</span> <span class="kn">import</span> <span class="n">PhantomPin</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">prev_nets</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="bp">self</span><span class="p">])</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="bp">self</span><span class="p">])</span>
        <span class="n">prev_pins</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([])</span>
        <span class="n">pins</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_pins</span><span class="p">)</span>
        <span class="k">while</span> <span class="n">pins</span> <span class="o">!=</span> <span class="n">prev_pins</span><span class="p">:</span>

            <span class="c1"># Add the nets attached to any unvisited pins.</span>
            <span class="k">for</span> <span class="n">pin</span> <span class="ow">in</span> <span class="n">pins</span> <span class="o">-</span> <span class="n">prev_pins</span><span class="p">:</span>
                <span class="c1"># No use visiting a pin that is not connected to a net.</span>
                <span class="k">if</span> <span class="n">pin</span><span class="o">.</span><span class="n">is_connected</span><span class="p">():</span>
                    <span class="n">nets</span> <span class="o">|=</span> <span class="nb">set</span><span class="p">(</span><span class="n">pin</span><span class="o">.</span><span class="n">nets</span><span class="p">)</span>

            <span class="c1"># Update the set of previously visited pins.</span>
            <span class="n">prev_pins</span> <span class="o">=</span> <span class="n">copy</span><span class="p">(</span><span class="n">pins</span><span class="p">)</span>

            <span class="c1"># Add the pins attached to any unvisited nets.</span>
            <span class="k">for</span> <span class="n">net</span> <span class="ow">in</span> <span class="n">nets</span> <span class="o">-</span> <span class="n">prev_nets</span><span class="p">:</span>
                <span class="n">pins</span> <span class="o">|=</span> <span class="nb">set</span><span class="p">(</span><span class="n">net</span><span class="o">.</span><span class="n">_pins</span><span class="p">)</span>

            <span class="c1"># Update the set of previously visited nets.</span>
            <span class="n">prev_nets</span> <span class="o">=</span> <span class="n">copy</span><span class="p">(</span><span class="n">nets</span><span class="p">)</span>

        <span class="c1"># Remove any phantom pins that may have existed for tieing nets together.</span>
        <span class="n">pins</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">pins</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">PhantomPin</span><span class="p">)])</span>

        <span class="c1"># Store the traversal.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span> <span class="o">=</span> <span class="n">Traversal</span><span class="p">(</span><span class="n">nets</span><span class="o">=</span><span class="nb">list</span><span class="p">(</span><span class="n">nets</span><span class="p">),</span> <span class="n">pins</span><span class="o">=</span><span class="nb">list</span><span class="p">(</span><span class="n">pins</span><span class="p">))</span>

        <span class="c1"># Every net connected to this one should have the same traversal.</span>
        <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span><span class="o">.</span><span class="n">nets</span><span class="p">:</span>
            <span class="n">n</span><span class="o">.</span><span class="n">traversal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">traversal</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">width</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return width of a Net, which is always 1.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="mi">1</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get, set and delete the name of this net.</span>

<span class="sd">        When setting the net name, if another net with the same name</span>
<span class="sd">        is found, the name for this net is adjusted to make it unique.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="nb">super</span><span class="p">(</span><span class="n">Net</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">name</span>

    <span class="nd">@name</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="c1"># Remove the existing name so it doesn&#39;t cause a collision if the</span>
        <span class="c1"># object is renamed with its existing name.</span>
        <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>

        <span class="c1"># Now name the object with the given name or some variation</span>
        <span class="c1"># of it that doesn&#39;t collide with anything else in the list.</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">Net</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">fset</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">get_unique_name</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">circuit</span><span class="o">.</span><span class="n">nets</span><span class="p">,</span> <span class="s2">&quot;name&quot;</span><span class="p">,</span> <span class="n">NET_PREFIX</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span>
        <span class="p">)</span>

    <span class="nd">@name</span><span class="o">.</span><span class="n">deleter</span>
    <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">Net</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">fdel</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">pins</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_pins</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">nets</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_nets</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">netclass</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get, set and delete the net class assigned to this net.</span>

<span class="sd">        If not net class is set, then reading the net class returns None.</span>

<span class="sd">        You can&#39;t overwrite the net class of a net once it&#39;s set.</span>
<span class="sd">        You&#39;ll have to delete it and then set it to a new value.</span>

<span class="sd">        Also, assigning a net class of None will have no affect on the</span>
<span class="sd">        existing net class of a net.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">&quot;_netclass&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

    <span class="nd">@netclass</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">netclass</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">netclass</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>

        <span class="c1"># Just leave the existing net class at its current value if setting the</span>
        <span class="c1"># net class to None. This is useful when merging nets because you just</span>
        <span class="c1"># assign each net the net class of the other and they should both get</span>
        <span class="c1"># the same net class (either None or the value of the net class of one,</span>
        <span class="c1"># the other, or both.)</span>
        <span class="k">if</span> <span class="n">netclass</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span>

        <span class="c1"># A net class can only be assigned if there is no existing net class</span>
        <span class="c1"># or if the existing net class matches the net class parameter (in</span>
        <span class="c1"># which case this is redundant).</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>  <span class="c1"># Get all interconnected subnets.</span>
        <span class="n">netclasses</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="nb">getattr</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="s2">&quot;_netclass&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">nets</span><span class="p">])</span>
        <span class="n">netclasses</span><span class="o">.</span><span class="n">discard</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">netclasses</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">pass</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">netclasses</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">netclass</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">netclasses</span><span class="p">:</span>
                <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                    <span class="ne">ValueError</span><span class="p">,</span>
                    <span class="s2">&quot;Can&#39;t assign net class </span><span class="si">{netclass.name}</span><span class="s2"> to net </span><span class="si">{self.name}</span><span class="s2"> that&#39;s already assigned net class </span><span class="si">{netclasses}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="o">**</span><span class="nb">locals</span><span class="p">()</span>
                    <span class="p">),</span>
                <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
                <span class="ne">ValueError</span><span class="p">,</span>
                <span class="s2">&quot;Too many netclasses assigned to net </span><span class="si">{self.name}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="o">**</span><span class="nb">locals</span><span class="p">()),</span>
            <span class="p">)</span>

        <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">nets</span><span class="p">:</span>
            <span class="n">n</span><span class="o">.</span><span class="n">_netclass</span> <span class="o">=</span> <span class="n">netclass</span>

    <span class="nd">@netclass</span><span class="o">.</span><span class="n">deleter</span>
    <span class="k">def</span> <span class="nf">netclass</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>  <span class="c1"># Get all interconnected subnets.</span>
        <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">nets</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_netclass</span>
            <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
                <span class="k">pass</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">drive</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get, set and delete the drive strength of this net.</span>

<span class="sd">        The drive strength cannot be set to a value less than its current</span>
<span class="sd">        value. So as pins are added to a net, the drive strength reflects the</span>
<span class="sd">        maximum drive value of the pins currently on the net.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>  <span class="c1"># Get all interconnected subnets.</span>
        <span class="n">max_drive</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">nets</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span><span class="o">.</span><span class="n">_drive</span><span class="p">)</span><span class="o">.</span><span class="n">_drive</span>
        <span class="k">return</span> <span class="n">max_drive</span>

    <span class="nd">@drive</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">drive</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">drive</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>  <span class="c1"># Get all interconnected subnets.</span>
        <span class="n">max_drive</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">nets</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span><span class="o">.</span><span class="n">_drive</span><span class="p">)</span><span class="o">.</span><span class="n">_drive</span>
        <span class="n">max_drive</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">drive</span><span class="p">,</span> <span class="n">max_drive</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">nets</span><span class="p">:</span>
            <span class="n">n</span><span class="o">.</span><span class="n">_drive</span> <span class="o">=</span> <span class="n">max_drive</span>

    <span class="nd">@drive</span><span class="o">.</span><span class="n">deleter</span>
    <span class="k">def</span> <span class="nf">drive</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="n">nets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nets</span>  <span class="c1"># Get all interconnected subnets.</span>
        <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">nets</span><span class="p">:</span>
            <span class="k">del</span> <span class="n">n</span><span class="o">.</span><span class="n">_drive</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">stub</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stub</span>

    <span class="nd">@stub</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">stub</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">val</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_stub</span> <span class="o">=</span> <span class="n">val</span>
        <span class="k">for</span> <span class="n">pin</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_pins</span><span class="p">():</span>
            <span class="n">pin</span><span class="o">.</span><span class="n">stub</span> <span class="o">=</span> <span class="n">val</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">valid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_valid</span>

    <span class="nd">@valid</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">valid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">val</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_validity</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_valid</span> <span class="o">=</span> <span class="n">val</span>

<div class="viewcode-block" id="Net.test_validity">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.Net.test_validity">[docs]</a>
    <span class="k">def</span> <span class="nf">test_validity</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid</span><span class="p">:</span>
            <span class="k">return</span>
        <span class="n">active_logger</span><span class="o">.</span><span class="n">raise_</span><span class="p">(</span>
            <span class="ne">ValueError</span><span class="p">,</span>
            <span class="s2">&quot;Net </span><span class="si">{}</span><span class="s2"> is no longer valid. Do not use it!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">),</span>
        <span class="p">)</span></div>
</div>



<div class="viewcode-block" id="NCNet">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.NCNet">[docs]</a>
<span class="nd">@export_to_all</span>
<span class="k">class</span> <span class="nc">NCNet</span><span class="p">(</span><span class="n">Net</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Lists of unconnected pins are stored using this Net subclass.</span>

<span class="sd">    This is a netlist subclass used for storing lists of pins which are</span>
<span class="sd">    explicitly specified as not being connected. This means the ERC won&#39;t</span>
<span class="sd">    flag these pins as floating, but no net connections for these pins</span>
<span class="sd">    will be placed in the netlist so there will actually be no</span>
<span class="sd">    connections to these pins in the physical circuit.</span>

<span class="sd">    Args:</span>
<span class="sd">        name: A string with the name of the net. If None or &#39;&#39;, then</span>
<span class="sd">            a unique net name will be assigned.</span>
<span class="sd">        *pins_nets_buses: One or more Pin, Net, or Bus objects or</span>
<span class="sd">            lists/tuples of them to be connected to this net.</span>

<span class="sd">    Keyword Args:</span>
<span class="sd">        attribs: A dictionary of attributes and values to attach to</span>
<span class="sd">            the object.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">):</span>
        <span class="kn">from</span> <span class="nn">.pin</span> <span class="kn">import</span> <span class="n">Pin</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">circuit</span><span class="o">=</span><span class="n">circuit</span><span class="p">,</span> <span class="o">*</span><span class="n">pins_nets_buses</span><span class="p">,</span> <span class="o">**</span><span class="n">attribs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_drive</span> <span class="o">=</span> <span class="n">Pin</span><span class="o">.</span><span class="n">drives</span><span class="o">.</span><span class="n">NOCONNECT</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">do_erc</span> <span class="o">=</span> <span class="kc">False</span>  <span class="c1"># No need to do ERC on no-connect nets.</span>

<div class="viewcode-block" id="NCNet.generate_netlist_net">
<a class="viewcode-back" href="../../rst_output/skidl.net.html#skidl.net.NCNet.generate_netlist_net">[docs]</a>
    <span class="k">def</span> <span class="nf">generate_netlist_net</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tool</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;NO_CONNECT nets don&#39;t generate anything for netlists.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="s2">&quot;&quot;</span></div>


    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">drive</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get the drive strength of this net.</span>

<span class="sd">        The drive strength is always NOCONNECT_DRIVE. It can&#39;t be changed.</span>
<span class="sd">        The drive strength cannot be deleted.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_drive</span></div>

</pre></div>

            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SKiDL 1.2.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">skidl.net</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
    &#169; Copyright 2016-2024, Dave Vandenbout.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.3.7.
    </div>
  </body>
</html>